package mytest.wd;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test5 {

    public static void main(String[] args) {
        String nowDate = "2028-02-29";

        String regex = "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(nowDate);
        if (!matcher.matches()) {
            System.out.println("false");
            return;
        }

        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        dateFormat.setLenient(false);

        try {
            dateFormat.parse(nowDate);
            System.out.println("success");
        } catch (ParseException e) {
            System.out.println("false");
        }
    }

}
